package com.bookheaven.core.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import entity.base.BaseEntity;

@Entity
@Table(name = "USERS")
public class User extends BaseEntity {
	
	private static final long	serialVersionUID	= -9055900697991877349L;
	
	@Column(name = "USER_NAME", nullable = false, length = 30)
	private String				userName;
	
	@Column(name = "FIRST_NAME", nullable = false, length = 30)
	private String				userFirstName;
	
	@Column(name = "LAST_NAME", nullable = false, length = 50)
	private String				userLastName;
	
	@Column(name = "MEMBERSHIP_DATE")
	private Date				userMembershipDate;
	
	@Column(name = "IS_ADMIN", nullable = false)
	private Boolean				isAdmin				= false;
	
	@Column(name = "PASSWORD_HASH", length = 255)
	private String				userPasswordHash;
	
	@Column(name = "EMAIL", length = 255)
	private String				userEmail;
	
	@Column(name = "LEVEL")
	private Integer				userLevel;
	
	@Transient
	private String				userPassword;
	
	@Column(name = "FLD_USER_IS_ACTIVE", nullable = false)
	private Boolean				isActive			= true;
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "commentUser")
	private List<Comment>		commentList			= new ArrayList<Comment>();
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "likeUser")
	private List<Like>			likeList			= new ArrayList<Like>();
	
	public String getUserName() {
		return userName;
	}
	
	public void setUserName(String userName) {
		this.userName = userName;
	}
	
	public String getUserFirstName() {
		return userFirstName;
	}
	
	public void setUserFirstName(String userFirstName) {
		this.userFirstName = userFirstName;
	}
	
	public String getUserLastName() {
		return userLastName;
	}
	
	public void setUserLastName(String userLastName) {
		this.userLastName = userLastName;
	}
	
	public Date getUserMembershipDate() {
		return userMembershipDate;
	}
	
	public void setUserMembershipDate(Date userMembershipDate) {
		this.userMembershipDate = userMembershipDate;
	}
	
	public Boolean getIsAdmin() {
		return isAdmin;
	}
	
	public void setIsAdmin(Boolean isAdmin) {
		this.isAdmin = isAdmin;
	}
	
	public String getUserPasswordHash() {
		return userPasswordHash;
	}
	
	public void setUserPasswordHash(String userPasswordHash) {
		this.userPasswordHash = userPasswordHash;
	}
	
	public Integer getUserLevel() {
		return userLevel;
	}
	
	public void setUserLevel(Integer userLevel) {
		this.userLevel = userLevel;
	}
	
	public String getUserPassword() {
		return userPassword;
	}
	
	public void setUserPassword(String userPassword) {
		this.userPassword = userPassword;
	}
	
	public Boolean getIsActive() {
		return isActive;
	}
	
	public void setIsActive(Boolean isActive) {
		this.isActive = isActive;
	}
	
	public String getUserEmail() {
		return userEmail;
	}
	
	public void setUserEmail(String userEmail) {
		this.userEmail = userEmail;
	}
	
	public List<Comment> getCommentList() {
		return commentList;
	}
	
	public void setCommentList(List<Comment> commentList) {
		this.commentList = commentList;
	}
	
	public List<Like> getLikeList() {
		return likeList;
	}
	
	public void setLikeList(List<Like> likeList) {
		this.likeList = likeList;
	}
	
	@Override
	public String toString() {
		return userName;
	}
	
}
